package com.budwk.app.sqfwV2.enums;

import cn.hutool.core.collection.CollectionUtil;
import com.budwk.app.sqfw.enums.SupportBusinessTypeEnum;
import com.budwk.app.sqfwDoc.codeGenerator.excelGenerate.BaseTemplateExcelGenerator;
import com.budwk.app.sqfwV2.dto.dto.OneFivePdfDTO;
import com.budwk.app.sqfwV2.dto.dto.childrenVisits.ChildrenVisitationPdfDTO;
import com.budwk.app.sqfwV2.dto.shawenTown.ShawenTownSafetyPdfDTO;
import com.budwk.app.sqfwV2.generator.childrenVisitation.excel.ChildrenVisitsLedger;
import com.budwk.app.sqfwV2.generator.childrenVisitation.pdf.ChildrenVisitsWord;
import com.budwk.app.sqfwV2.generator.oneFive.pdf.OneFiveDocGenerator;
import com.budwk.app.sqfwV2.generator.shawenTown.excel.ElectricBicycleLedgerGenerator;
import com.budwk.app.sqfwV2.generator.shawenTown.excel.FirePublicityLedgerGenerator;
import com.budwk.app.sqfwV2.generator.shawenTown.excel.SmallPremisesInspectionGenerator;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor
public enum FileServiceConfigEnum {

    // 儿童探访记录表
    CA(SupportBusinessTypeEnum.CHILDREN_VISITATION.getName(), "儿童探访记录表", ChildrenVisitsWord.class, ChildrenVisitationPdfDTO.class, "children_visits_records_doc", "sqfwV2/childrenVisits/childrenVisitsRecordWord.docx", "33bc3b0158a94d68a14a707b940c28ba", "/preview/childrenVisits/children_visits_records_doc.png", "儿童探访记录表", 1, "pdf", null),
    CB(SupportBusinessTypeEnum.CHILDREN_VISITATION.getName(), "儿童探访记录台账", ChildrenVisitsLedger.class, ChildrenVisitationPdfDTO.class, "children_visits_records__ledger", "sqfwV2/childrenVisits/childrenVisitsRecordLedger.xlsx", "c9e4306ec9614b72ad1610c5bf901f49", "/preview/childrenVisits/children_visits_records_ledger.png", "儿童探访记录表", 2, "excel", null),


    // 白云安全排查
    BYA(SupportBusinessTypeEnum.BATYUN_SAFE.getName(), "村（居）电动自行车排查整治台账", ElectricBicycleLedgerGenerator.class, ShawenTownSafetyPdfDTO.class,"shawen_town_electric_bicycle_ledger", "sqfwV2/shawenTown/electricBicycleLedger.xlsx", "677c53af8c1d4a109e93f7718d33e244", "/preview/safety/baiyun/shawen_town_electric_bicycle_ledger.png", "统计|时间筛选|电动车", 1, "excel", null),
    BYB(SupportBusinessTypeEnum.BATYUN_SAFE.getName(), "“三合一场所”消防安全巡查台账", SmallPremisesInspectionGenerator.class, ShawenTownSafetyPdfDTO.class,"small_business_premises_fire_safety_inspection", "sqfwV2/shawenTown/smallBusinesPremisesInspection.xlsx", "2024dsfservdfwewq2333294ddd4c379e", "/preview/safety/baiyun/small_business_premises_fire_safety_inspection.png", "台账|小型经营场所", 2, "excel", null),
    BYC(SupportBusinessTypeEnum.BATYUN_SAFE.getName(), "消防宣传台账", FirePublicityLedgerGenerator.class, ShawenTownSafetyPdfDTO.class,"shawen_town_fire_publicity_ledger", "sqfwV2/shawenTown/firePublicityLedger.xlsx", "c067ab9daee84041bb3bfbfe1a13c222", "/preview/safety/baiyun/shawen_town_fire_publicity_ledger.png", "台账|小型经营场所", 3, "excel", null),
    BYD(SupportBusinessTypeEnum.BATYUN_SAFE.getName(), "【安全排查整治表】合集", null, ShawenTownSafetyPdfDTO.class,"shawentown_safety_rectification_pdf", "sqfwV2/shawenTown/template/shawenTownSafeWordTemplate.docx", "49662da2c0154cb6b4df2d2a7e602a92", "/preview/safety/baiyun/shawentown_safety_rectification_pdf1.png,/preview/safety/baiyun/shawentown_safety_rectification_pdf2.png", "安全巡查", 4, "pdf", "sqfwV2/shawenTown/template/shawenTownSafeWordTemplate.docx"),


    // 12345
    OOA(SupportBusinessTypeEnum.ONE_TO_FIVE.getName(), "案件说明情况", OneFiveDocGenerator.class, OneFivePdfDTO.class,"one_to_five_doc", "sqfwV2/oneFive/oneFiveDoc.docx", "5259796719534c558d0a4c7d5ab13514", "/preview/of/od01.jpg", "案件说明", 1, "pdf", "sqfwV2/oneFive/template/oneFiveDocTemplate.docx"),
    // 防汛助手
    OFA(SupportBusinessTypeEnum.FLOOD_CONTROL_ASSISTANT.getName(), "案件说明情况", OneFiveDocGenerator.class, OneFivePdfDTO.class,"flood_control_assistant_pdf_doc", "sqfwV2/oneFive/oneFiveDoc.docx", "8c0cbebf85a541db9168de81690540ed", "/preview/of/od01.jpg", "案件说明", 1, "pdf", "sqfwV2/oneFive/template/oneFiveDocTemplate.docx"),



    ;

    private String fillType;
    private String fileName;
    private Class<?> service;
    private Class<?> pdfEntityPath;
    private String code;
    private String filePath;
    private String templateId;
    private String previewImage;
    private String label;
    private Integer location;
    private String fileType;
    private String templatePath;


    public static List<FileServiceConfigEnum> findByFillType(String fillType, String fileType) {
        List<FileServiceConfigEnum> list = Arrays.stream(values()).filter(e -> e.getFillType().equals(fillType)).collect(Collectors.toList());
        if (CollectionUtil.isEmpty(list)) {
            return Lists.newArrayList();
        }
        if (StringUtils.isNotEmpty(fileType)) {
            List<FileServiceConfigEnum> enumList = list.stream().filter(e -> e.getFileType().equals(fileType)).collect(Collectors.toList());
            return enumList;
        }
        return list;
    }

    public static FileServiceConfigEnum findByCode(String fillType, String code) {
        Optional<FileServiceConfigEnum> first = Arrays.stream(values()).filter(e -> e.getFillType().equals(fillType) && e.getCode().equals(code)).findFirst();
        return first.orElse(null);
    }
}
